package com.lytfly.flowable.utils;

/**
 * EL表达式工具类
 *
 * @author liuyuantao
 */
public class ElUtil {

    static final String INDEX_OF_1 = "${";
    static final String INDEX_OF_2 = ".";

    /**
     * 获取uel表达式里面的变量名
     *
     * @param elStr
     * @return
     */
    public static String getOriginalValue(String elStr) {
        if (elStr.contains(INDEX_OF_1)) {
            elStr = elStr.substring(elStr.lastIndexOf(INDEX_OF_1) + 2, elStr.length() - 1).trim();
        }
        return elStr;
    }

    /**
     * 获取字符串变量点前面的变量名
     *
     * @param elStr
     * @return
     */
    public static String getSpotValue(String elStr) {
        if (elStr.contains(INDEX_OF_2)) {
            elStr = elStr.substring(0, elStr.indexOf(INDEX_OF_2)).trim();
        }
        return elStr;
    }


    public static void main(String[] args) {
        String originalValue = ElUtil.getSpotValue("line.sfdsf");
        System.out.println(originalValue);
    }
}
